﻿// 开发者:micropu
// 公司:佛山远钧智慧科技有限公司

using log4net.Util;
using Microsoft.CodeAnalysis;
using Microsoft.OpenApi.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Admin.NET.Application.LogService;

/// <summary>
/// 住建日志服务
/// </summary>
public class ZJLog
{
    private readonly ISqlSugarClient _db;

    public ZJLog()
    {
        _db = App.GetService<ISqlSugarClient>();
    }

    /// <summary>
    /// 设备日志
    /// </summary>
    /// <returns></returns>
    public async Task LogDevice(Microsoft.Extensions.Logging.LogLevel logLevel,
        LogType logType,string Message,string ClientSn,long projectId,long tenantId,
        long createOrgId,string createOrgName)
    {
        await _db.Insertable(new DevicesLog
        {
            LogLevel = logLevel.GetDisplayName(),
            LogType = logType,
            Name = Message,
            ClientSn = ClientSn,
            ProjectId = projectId,
            TenantId = tenantId,
            CreateOrgId = createOrgId,
            CreateOrgName = createOrgName,
            CreateTime = DateTime.Now,
            IsDelete = false,
        }).ExecuteCommandAsync();
    }

    /// <summary>
    /// 住建平台日志
    /// </summary>
    /// <returns></returns>
    public async Task LogPlat(Microsoft.Extensions.Logging.LogLevel logLevel,
        LogType logType, string Message, string ClientSn, long projectId, long tenantId,
        long createOrgId, string createOrgName)
    {
        await _db.Insertable(new PlatformLog
        {
            LogLevel = logLevel.GetDisplayName(),
            LogType = logType,
            Name = Message,
            ClientSn = ClientSn,
            ProjectId = projectId,
            TenantId = tenantId,
            CreateOrgId = createOrgId,
            CreateOrgName = createOrgName,
            CreateTime = DateTime.Now,
            IsDelete = false,
        }).ExecuteCommandAsync();
    }

}
